import Vue from 'vue';
import VueRouter from 'vue-router';

const Home = () => import('views/home/Home');
const Category = () => import('views/category/Category');
const Cart = () => import('views/cart/Cart');
const Profile = () => import('views/profile/Profile');
const Detail = () => import('views/detail/Detail');
const Autumn = () => import('components/content/autumn/autumn');
const Beauty = () => import('components/content/beauty/beauty');

Vue.use(VueRouter);

const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error);
}

const routes = [
  {
    path: '/beauty',
    component: Beauty
  },
  {
    path: '/autumn',
    component: Autumn
  },
  {
    path: "/detail/:id",
    component: Detail
  },
  {
    path: "/profile",
    component: Profile,
    name: 'profile'
  },
  {
    path: "/cart",
    component: Cart,
    name: 'carts'
  },
  {
    path: "/category",
    component: Category,
    name: 'categorys'
  },
  {
    path: "/home",
    component: Home,
    name: 'homes'
  },
  {
    path: "",
    redirect: "/home"
  }
];

const router = new VueRouter({
  mode: 'history',
  routes
});

export default router;